#!/usr/bin/python3
# coding:utf-8
#
#httpget返回
def TestUrlOpen():
  import urllib.request
  page = urllib.request.urlopen("http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getWeatherbyCityName?theCityName=58367")
  print(page)
  lines = page.readlines()
  print(lines)
  page.close()
  document = ""
  for line in lines :
      print(document)
      document = document + line.decode('utf-8')

  from xml.dom.minidom import parseString
  dom =parseString(document)
  strings = dom.getElementsByTagName("string")
  print (strings[6].childNodes[0].data + " " + strings[7].childNodes[0].data)

def TestSubs():
    from suds.client import Client
    from suds.xsd.doctor import Import, ImportDoctor
    url = 'http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl'
    imp = Import('http://www.w3.org/2001/XMLSchema',location='http://www.w3.org/2001/XMLSchema.xsd')
    imp.filter.add('http://WebXml.com.cn/')

    client = Client(url, doctor=ImportDoctor(imp))
    print(client)
    #print(client.service.getWeather('58367'))



if __name__ == '__main__':
    #TestUrlOpen()
    TestSubs()